package top.itpath.common.util;

import cn.hutool.extra.spring.SpringUtil;
import org.springframework.stereotype.Component;
import top.itpath.admin.dto.UserInfo;
import top.itpath.admin.entity.SysUser;
import top.itpath.admin.service.IUserService;

/**
 * 当前用户工具
 *
 * @author zhaomengru
 * @time 2023/10/11 - 21:26
 */
@Component
public class UserUtil {

    public static UserInfo getCurrentUser() {
        String token = RequestUtil.getToken();
        SysUser sysUser = JwtUtil.parseToken(token);
        IUserService userService = SpringUtil.getBean(IUserService.class);
        return userService.getUserInfo(sysUser.getId());
    }
}
